﻿(function () {

    window.crucible = window.crucible || {};
    var c = window.crucible;

    c.userId = null; // this will be the logged in user id. Don't trust it for security, that layer is server side.

    c.NodeType = {
        assertion: 1,
        interpretation: 2,
        source: 3,
        originator: 4
    };
    
    c.NodeTypeName = function (type) {
        if (type == c.NodeType.assertion) { return "Assertion"; }
        if (type == c.NodeType.interpretation) { return "Interpretation"; }
        if (type == c.NodeType.axiom) { return "Axiom"; }
        if (type == c.NodeType.source) { return "Source"; }
        if (type == c.NodeType.originator) { return "Originator"; }
        return null;
    };
    
    if ($.pnotify) {
        $.pnotify.defaults.styling = "jqueryui";
        $.pnotify.defaults.delay = 3000;
        $.pnotify.defaults.history = false;
    }

    c.mixprops = {
        errorMessage: "Error Message",
        nodeId: "Node Id",
        nodeTitle: "Node Title"
    };

    c.mixevents = {
        saveDraft: "Save Draft",
        saveStub: "Save Stub",
        publish: "Publish"
    };
    
    c.raiseError = function(message, notify, track) {

        if (notify && $.pnotify) {
            $.pnotify({ title: "Error", text: message, type: 'error' });
        }

        if (track && mixpanel) {
            var props = {};
            props[c.mixprops.errorMessage] = message;
            mixpanel.track("Error", props);
        }
    };
    

}());